package dynamic.ibatis.builder;

import dynamic.ibatis.mapping.DBoundSql;
import dynamic.ibatis.mapping.DParameterMapping;
import dynamic.ibatis.mapping.DSqlSource;
import dynamic.ibatis.session.DConfiguration;
import org.apache.ibatis.mapping.ParameterMapping;

import java.util.List;

/**
 * @author Clinton Begin
 */
public class DStaticSqlSource implements DSqlSource {

    private final String sql;
    private final List<DParameterMapping> parameterMappings;
    private final DConfiguration configuration;

    public DStaticSqlSource(DConfiguration configuration, String sql) {
        this(configuration, sql, null);
    }

    public DStaticSqlSource(DConfiguration configuration, String sql, List<DParameterMapping> parameterMappings) {
        this.sql = sql;
        this.parameterMappings = parameterMappings;
        this.configuration = configuration;
    }

    @Override
    public DBoundSql getBoundSql(Object parameterObject) {
        return new DBoundSql(configuration, sql, parameterMappings, parameterObject);
    }

}
